package com.dcsgo.v1ch03;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Scanner;

/**
 * 
 * @ClassName: ScannerReadFile
 * @Description:通过Scanner读取文件中的数据 
 * @author DCSGO
 * @date 2023-10-29 08:42:08
 */
public class ScannerReadFile {
	public static void main(String[] args) throws IOException{
		Scanner in = new Scanner(Path.of("src\\com\\dcsgo\\v1ch03\\content.txt"),
				StandardCharsets.UTF_8);
		System.out.println(in.nextLine());
		System.out.println(in.nextLine());
		System.out.println(in.nextInt());
		System.out.println(in.nextDouble());
		System.out.println(in.nextBoolean());
/*
这是一个用于测试通过Scanner读取文件的测试文件
java.lang.NullPointerException: Cannot invoke "java.io.Console.readLine(String, Object[])" because "cons" is null
1234
3.1415926
false
*/
		//java.util.Scanner(更新于Java5)
		//Scanner(Path p,String encoding)
		//构造一个Scanner使用给定字符编码从给定路径读取数据。
		//java.nio.file.Path 
		//static Path of(String pathname) 
		//由给定的路径名构造一个Path。(更新于Java11)
	}
}
